package cn.imokay.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


//如果要做forward跳转不能使用restcontroller注解
@Controller
public class HelloControllerForForward {


    @GetMapping(value = "/goto")
    public String gotoForward(HttpServletRequest request) {
        request.setAttribute("f1_name", "gotoForward");
        request.setAttribute("f1_path", "goto");

        return "forward:/doForward";
    }

    @ResponseBody
    @GetMapping(value = "/doForward")
    public Map doForward(@RequestAttribute String f1_name,
                         @RequestAttribute("f1_path") String path) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("f1_name", f1_name);
        map.put("path", path);

        return map;
    }


    @GetMapping(value = "gotoindex")
    public String gotoIndex() {

        return "forward:/index.html";
    }
}
